﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TunaInterpreter2.Classes
{
    public class ScriptData
    {
        public Dictionary<string, int> intVariables = new Dictionary<string, int>(); // nazwa, wartość
        public Dictionary<string, float> floatVariables = new Dictionary<string, float>(); // nazwa, wartość
        public Dictionary<string, string> stringVariables = new Dictionary<string, string>(); // nazwa, wartość
        public Dictionary<string, int> labelsList = new Dictionary<string, int>(); //nazwa, linia=pozycja tablicy
        public string[] source;

        public bool addInt(string str)
        {
            string[] words = str.Split(new char[] { ' ' });
            if (intVariables.ContainsKey(words[1]))
            {
                return false;
            }
            else
            {
                intVariables.Add(words[1], 0);
                return true;
            }


        }

        public bool addFloat(string str)
        {
            string[] words = str.Split(new char[] { ' ' });
            if (floatVariables.ContainsKey(words[1]))
            {
                return false;
            }
            else
            {
                floatVariables.Add(words[1], 0);
                return true;
            }

        }

        public bool addString(string str)
        {
            string[] words = str.Split(new char[] { ' ' });
            if (stringVariables.ContainsKey(words[1]))
            {
                return false;
            }
            else
            {
                stringVariables.Add(words[1], "");
                return true;
            }
            
        }

        public bool addLabel(string str, int numline)
        {
            string[] words = str.Split(new char[] { ':' });
            if (labelsList.ContainsKey(words[1]))
            {
                return false;
            }
            else
            {
                labelsList.Add(words[1], numline);
                return true;
            }
            
        }
    }
}
